﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace SD.EF
{
    public class DatabaseInitializer : DropCreateDatabaseAlways<SdContext>
    {
        protected override void Seed(SdContext context)
        {
            var films = new List<FilmEntity>
            {
                new FilmEntity { 
                    Id = Guid.NewGuid(), 
                    KeyName = "Orga",
                    BigImg = "demo-movie.jpg",
                    SmallImg = "demo-teaser.jpg",
                    EnName = "GONE GIRL",
                    DeName = "1Das perfekte Opfer - Film 2014",
                    Regisseur = "David Fincher",
                    Darsteller = "Ben Affleck, Rosamund Pike, Tyler Perry, Neil Patrick Harris, David Clennon, Missi Pyle",
                    Laufzeit = "149 Min.",
                    Altersfreigabe = "FSK 16",
                    Verleihrechte = "Twentieth Century Fox of Germany GmbH",
                    Inhalt = "With his wife's disappearance having become the focus of an intense media circus, a man sees the spotlight turned on him when it's suspected that he may not be innocent.",
                    Recommended = true,
                    New = false,
                    MostViewed = true,
                    Specials = false
                },
                new FilmEntity {
                    Id = Guid.NewGuid(), 
                    KeyName = "Orga2",
                    BigImg = "demo-movie.jpg",
                    SmallImg = "demo-teaser.jpg",
                    EnName = "GONE GIRL",
                    DeName = "2Das perfekte Opfer - Film 2014",
                    Regisseur = "David Fincher",
                    Darsteller = "Ben Affleck, Rosamund Pike, Tyler Perry, Neil Patrick Harris, David Clennon, Missi Pyle",
                    Laufzeit = "149 Min.",
                    Altersfreigabe = "FSK 16",
                    Verleihrechte = "Twentieth Century Fox of Germany GmbH",
                    Inhalt = "With his wife's disappearance having become the focus of an intense media circus, a man sees the spotlight turned on him when it's suspected that he may not be innocent.",
                    Recommended = false,
                    New = true,
                    MostViewed = true,
                    Specials = false
                }
            };

            films.ForEach(s => context.Films.Add(s));

            context.SaveChanges();

            context.Watchs.Add(new WatchEntity { Id = Guid.NewGuid(), FilmId = films[0].Id });
            context.Watchs.Add(new WatchEntity { Id = Guid.NewGuid(), FilmId = films[0].Id });
            context.Watchs.Add(new WatchEntity { Id = Guid.NewGuid(), FilmId = films[1].Id });
            context.Watchs.Add(new WatchEntity { Id = Guid.NewGuid(), FilmId = films[1].Id });


            context.Buyings.Add(new BuyingEntity { Id = Guid.NewGuid(), FilmId = films[0].Id });


            context.SaveChanges();
        }

        public override void InitializeDatabase(SdContext context)
        {
            base.InitializeDatabase(context);
        }
    }
}